/*
 * This file is part of "Deathwatch Ammo Counter for Android".
 *
 * "Deathwatch Ammo Counter for Android" is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation, either version 3 of the License, 
 * or (at your option) any later version.
 *
 * "Deathwatch Ammo Counter for Android" is distributed in the hope that it 
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with "Deathwatch Ammo Counter for Android".  
 * If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package com.TikiiTorch.Deathwatch.AmmoCounter;

import java.util.ArrayList;

public class SpaceMarine {

	private String name = null;

	private int activeWeapon;

	private ArrayList<Weapon> weapons;

	public SpaceMarine() {
		this.name = new String();
		this.activeWeapon = 0;
		this.weapons = new ArrayList<Weapon>();
	}

	public SpaceMarine(String name, ArrayList<Weapon> weapons) {
		this.name = name;
		this.activeWeapon = 0;
		this.weapons = weapons;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void addWeapon(Weapon weapon) {
		weapons.add(weapon);
	}

	public void removeWeapon(int index) {
		weapons.remove(index);
	}

	public int weaponCount() {
		return weapons.size();
	}

	public ArrayList<Weapon> getWeapons() {
		return this.weapons;
	}

	public Weapon activeWeapon() {
		return weapons.get(activeWeapon);
	}

	public int getActiveWeapon() {
		return this.activeWeapon;
	}

	public void setActiveWeapon(int index) {
		if (index >= 0 && index < weapons.size()) {
			this.activeWeapon = index;
		} else {
			this.activeWeapon = 0;
		}
	}

	public String[] weaponList() {
		String[] weapList = new String[weapons.size()];

		for (int i = 0; i < weapons.size(); i++) {
			weapList[i] = weapons.get(i).getName();
		}

		return weapList;
	}

}
